-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detailed err message on wrong request url #903
Conversation
cli/src/utils.ts
Outdated
return 200 === (await axios.get(url))?.status | ||
} catch (e) { | ||
console.error(`Orakl Network Fetcher [${url}] is down`) | ||
if (!(await isValidUrl(url))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just suggestion. I think we should be careful with capturing more than unnecessary amount code with try
which might lead to code that is harder to read. Below, in the suggestion I move the try
branch below isValidUrl
which theoretically could lead to missing exception thrown by isValidUrl
function, however, the function does not throw anything and only returns boolean.
export async function isOraklFetcherHealthy(url: string) {
if (!(await isValidUrl(url))) {
console.error('Invalid URL')
return false
}
try {
const response = await axios.get(url)
if (response.status === 200) {
return true
} else {
console.error(`Orakl Network Fetcher [${url}] is down. HTTP Status: ${response.status}`)
return false
}
} catch (error) {
console.error(
`An error occurred while checking the Orakl Network Fetcher [${url}]: ${error.message}`
)
return false
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree with you, I will push again after fixing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just one small suggestion in the comment.
Description
Previously, when requested
cli fetcher active
with wrong host and port, it returned following messageOrakl Network Fetcher [${url}] is down
.Now it checks if url is valid and returns
Invalid URL
on wrong requestFixes # (issue)
Type of change
Please delete options that are not relevant.
Checklist before requesting a review
Deployment